<template>
  <a-card :bordered="false">

    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="姓名">
              <a-input placeholder="请输入姓名" v-model="queryParam.name"></a-input>
            </a-form-item>
          </a-col>

          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="年龄">
              <a-input placeholder="请输入年龄" v-model="queryParam.age"></a-input>
            </a-form-item>
          </a-col>

          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="需求类型">
              <a-select v-model="queryParam.demandType" placeholder="请选择需求类型">
                <a-select-option value="">全部</a-select-option>
                <a-select-option value="1">普通陪护</a-select-option>
                <a-select-option value="2">产房陪护</a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
		  <a-col :xl="6" :lg="7" :md="8" :sm="24">
		    <a-form-item label="手机号">
		  		<a-input placeholder="请输入手机号" v-model="queryParam.phoneNum"></a-input>
		    </a-form-item>
		  </a-col>
<!--          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="预产期">
              <a-input placeholder="请输入预产期" v-model="queryParam.expectedDate"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="第几胎">
              <a-input placeholder="请输入第几胎" v-model="queryParam.whichPregnant"></a-input>
            </a-form-item>
          </a-col>-->
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
            </span>
          </a-col>

        </a-row>
      </a-form>
    </div>

    <!-- 操作按钮区域 -->
<!--    <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
      </a-dropdown>
    </div>-->

    <!-- table区域-begin -->
    <div>
<!--      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>-->

      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        class="j-table-force-nowrap"
		 @change="handleTableChange">


        <span slot='demandTypeSlot' slot-scope="text, record">
           <a-tag color="blue" v-if='text.demandType==1'>普通陪护</a-tag>
          <a-tag color="green" v-if='text.demandType==2'>产护陪护</a-tag>
        </span>

        <span slot='nannyGradeSlot' slot-scope="text, record">
          <a-tag v-for='(ite,idx) in gradeList' :key="idx" :color='ite.color' v-if='text.nannyGrade == ite.value'>{{ite.name}}</a-tag>
        </span>
        <span slot='whichPregnant' slot-scope="text, record">
			{{record.whichPregnant == 1 ? '第一胎' : '第二胎'}}
		</span>
		<span slot='fetusNums' slot-scope="text, record">
			{{record.fetusNums == 1 ? '单胎' : '双胎'}}
		</span>
        <span slot='expDateSlot' slot-scope="text, record">
          <a-statistic-countdown  :value="text.expDate" format="D 天 H 时 m 分 s 秒" />
        </span>

        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">查看详情</a>
<!--
          <a-divider type="vertical" />
          <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
          </a-popconfirm>-->

        </span>

      </a-table>
    </div>
    <!-- table区域-end -->

    <!-- 表单区域 -->
    <wechatDemandRecord-modal ref="modalForm" @ok="modalFormOk"></wechatDemandRecord-modal>
  </a-card>
</template>

<script>
  import '@/assets/less/TableExpand.less'
  import WechatDemandRecordModal from './modules/WechatDemandRecordModal'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'

  export default {
    name: "DemandList",
    mixins:[JeecgListMixin],
    components: {
      WechatDemandRecordModal
    },
    data () {
      return {
        description: '需求记录管理页面',
        // 表头
        columns: [
		   {
            title: '姓名',
            align:"center",
            dataIndex: 'name'
           },
		   {
		    title: '手机号',
		    align:"center",
		    dataIndex: 'phoneNum'
		   },
          {
            title: '陪护类型',
            align:"center",
            scopedSlots: { customRender: 'demandTypeSlot' },
          },
		   {
            title: '年龄',
            align:"center",
            dataIndex: 'age'
           },
		   {
            title: '预产期',
            align:"center",
            dataIndex: 'expectedDate'
           },
		   {
            title: '第几胎',
            align:"center",
			scopedSlots: { customRender: 'whichPregnant' },
           },
		   {
            title: '单双胎',
            align:"center",
			scopedSlots: { customRender: 'fetusNums' },
           },
		   {
            title: '订单过期时间',
            align:"center",
            // dataIndex: 'expDate'
            scopedSlots: { customRender: 'expDateSlot' },

           },
		   {
            title: '上户时间',
            align:"center",
            dataIndex: 'regTime'
           },
		   {
            title: '上户天数',
            align:"center",
            dataIndex: 'regDay'
           },
		   {
            title: '月嫂等级',
            align:"center",
            scopedSlots: { customRender: 'nannyGradeSlot' },
            //dataIndex: 'nannyGrade'
           },
		   {
		    title: '创建时间',
		    align:"center",
		    dataIndex: 'createTime'
		   },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            scopedSlots: { customRender: 'action' },
          }
        ],
		url: {
          list: "/wechat/wechatDemandRecord/list",
          delete: "/wechat/wechatDemandRecord/delete",
          deleteBatch: "/wechat/wechatDemandRecord/deleteBatch",
          exportXlsUrl: "wechat/wechatDemandRecord/exportXls",
          importExcelUrl: "wechat/wechatDemandRecord/importExcel",
       },
    gradeList:[
      {name:'高级',value:'1',color:'pink'},
      {name:'金牌',value:'2',color:'blue'},
      {name:'钻石',value:'3',color:'orange'},
      {name:'明星',value:'4',color:'green'},
      {name:'首席',value:'5',color:'cyan'},
    ]
    }
  },
  computed: {
    importExcelUrl: function(){
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    }
  },
    methods: {

    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
  /deep/.ant-statistic-content-value{
	  font-size: 14px;
  }
</style>